package com.lyz.lambdas.streamDemo;

import java.util.*;
import java.util.stream.Stream;

/**
 * @ClassName StreamTest
 * @Description Stream流
 * @Author 2214361854
 * @Date 2022/2/23 13:07
 * @Version 1.0
 */
public class StreamTest {
    public static void main(String[] args) {
//        List<String> names = new ArrayList<>();
//        Collections.addAll(names,"张强","张小强","小张强","张部","周晓","赵敏");
//        System.out.println(names);
//        //满足首位是"张"且3位的名字
//        names.stream().filter(s -> s.startsWith("张")).filter(s -> s.length() == 3).forEach(s -> System.out.println(s));


        /**
         * 获取stream流（集合/数组）
         */
        Collection<String> list = new ArrayList<>();
        Stream<String> s = list.stream();

        Map<String,Integer> maps = new HashMap<>();
        //键流
        Stream<String> keyStream = maps.keySet().stream();
        //值流
        Stream<Integer> valueStream = maps.values().stream();
        //键值流
        Stream<Map.Entry<String,Integer>> keyAndValueStream = maps.entrySet().stream();

        String[] names = {"张强","张小强","小张强","张部"};
        Stream<String> namseStream = Arrays.stream(names);
        Stream<String> namseStream2 = Stream.of(names);


    }
}
